<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>基础表单</title>
    <link rel="stylesheet" href="__LIBS__/layui/css/layui.css" />
    <link rel="stylesheet" href="__MODULE__/admin.css?v=317" />
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
    <style>
        #formBasForm {
            width: 800px;
        }

        .layui-form-item {
            display: flex;
        }


        .layui-input-block {
            flex: 14;
        }

        .layui-input-block {
            margin-left: 20px !important;
            min-height: 36px;
        }

        .pictureNomer {
            flex: 7;
            height: 38px;
            line-height: 38px;
            margin-right: 5px;
        }
        .layui-upload-img {

            max-height: 200px;
            height: auto;
            margin: 0 10px 10px 0;
            cursor:pointer;
        }
        .imgs-box{
            display: flex;
        }
        #formBasForm .layui-form-item {
            margin-bottom: 25px;
        }
    </style>
</head>

<body>
<!-- 加载动画 -->
<div class="page-loading">
    <div class="ball-loader">
        <span></span><span></span><span></span><span></span>
    </div>
</div>
<!-- 正文开始 -->
<div class="layui-fluid">
    <div class="layui-card">
        <ul class="layui-tab-title" style="margin-bottom: 20px;">
            <li><a ew-href="{:url('storage')}">存储设置</a></li>
            <li><a ew-href="{:url('storageQiniu')}" ew-title="七牛云">七牛云</a></li>
            <li class="layui-this"><a href="javascript:location.reload();" ew-title="阿里云">阿里云</a></li>
            <!--<li><a ew-href="{:url('storageTencent')}" ew-title="腾讯云">腾讯云</a></li>-->
        </ul>
        <div class="layui-card-body">
            <!-- 表单开始 -->
            <form class="layui-form" id="formBasForm" lay-filter="formBasForm">
                <div class="layui-form-item">
                    <label class="layui-form-label layui-form-required">阿里云accessKeyId:</label>
                    <div class="layui-input-block">
                        <input name="accessKeyId" value="{$item['accessKeyId']??''}" placeholder="阿里云accessKey" class="layui-input" />
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label layui-form-required">阿里云accessKeySecret:</label>
                    <div class="layui-input-block">
                        <input name="accessKeySecret" value="{$item['accessKeySecret']}" placeholder="阿里云secretKey" class="layui-input" />
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label layui-form-required">阿里云bucket:</label>
                    <div class="layui-input-block">
                        <input name="oss[bucket]" value="{$item['oss']['bucket']}" placeholder="阿里云bucket 存储空间名" class="layui-input" />
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label layui-form-required">阿里云Endpoint（地域节点）:</label>
                    <div class="layui-input-block">
                        <input name="oss[endpoint]" value="{$item['oss']['endpoint']}" placeholder="阿里云Endpoint（地域节点）" class="layui-input" />
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label layui-form-required">Bucket 域名:</label>
                    <div class="layui-input-block">
                        <input name="oss[accessUrl]" value="{$item['oss']['accessUrl']}" placeholder="Bucket 域名" class="layui-input" />
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label ">授权用户访问RAM用户ID（非必填）:</label>
                    <div class="layui-input-block">
                        <input name="ram[accountID]" value="{$item['ram']['accountID']}" placeholder="RAM用户ID" class="layui-input" />
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label ">授权用户访问RAM用户名（非必填）:</label>
                    <div class="layui-input-block">
                        <input name="ram[roleName]" value="{$item['ram']['roleName']}" placeholder="RAM用户名" class="layui-input" />
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label ">水印位置:</label>
                    <div class="layui-upload layui-input-block">
                        <select name="watermark_location" id="">
                            <option value="TopLeft" {if isset($item['watermark_location']) && $item['watermark_location'] == 'TopLeft'}selected{/if}>左上角</option>
                            <option value="TopRight" {if isset($item['watermark_location']) && $item['watermark_location'] == 'TopRight'}selected{/if}>右上角</option>
                            <option value="BottomLeft" {if isset($item['watermark_location']) && $item['watermark_location'] == 'BottomLeft'}selected{/if}>左下角</option>
                            <option value="BottomRight" {if isset($item['watermark_location']) && $item['watermark_location'] == 'BottomRight'}selected{/if}>右下角</option>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-block" style="display: flex;
                    justify-content: space-around;
                ">
                        <button id="btnDemoEdtGetContent" class="layui-btn submitbtn" lay-filter="formBasSubmit" lay-submit>&emsp;提交&emsp;</button>
                        <button type="reset" class="layui-btn layui-btn-primary">&emsp;重置&emsp;</button>
                    </div>
                </div>
            </form>
            <!-- //表单结束 -->
        </div>
    </div>
</div>

<!-- js部分 -->
<script type="text/javascript" src="__LIBS__/layui/layui.js"></script>
<script type="text/javascript" src="__NJS__/common.js?v=317"></script>
<script type="text/javascript" src="__LIBS__/tinymce/tinymce.min.js"></script>
<script src="__LIBS__/jquery/jquery-3.2.1.min.js"></script>
<script>

    layui.use(['layer', 'form', 'laydate', 'jquery','upload','admin'], function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var form = layui.form;
        var laydate = layui.laydate;
        var upload = layui.upload;
        var admin = layui.admin;
        //普通图片上传
        var uploadInst = upload.render({
            elem: '#test1'
            ,url: "{:url('admin/Upload/uploadLocal')}" //改成您自己的上传接口
            ,before: function(obj){
                //预读本地文件示例，不支持ie8
                obj.preview(function(index, file, result){
                    $('#demo1').attr('src', result); //图片链接（base64）
                });
            }
            ,done: function(res){
                console.log(res)
                //如果上传失败
                if(res.code == 0){
                    $("input[name='share_icon']").val(res.data);
                }
                //上传成功
            }
            ,error: function(){
                //演示失败状态，并实现重传
                var demoText = $('#demoText');
                demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
                demoText.find('.demo-reload').on('click', function(){
                    uploadInst.upload();
                });
            }
        });
        /* 监听表单提交 */
        form.on('submit(formBasSubmit)', function (data) {
            $('.submitbtn').addClass('layui-disabled').attr('disabled','disabled');
            $.ajax({
                url:"{:url('storageAli')}",
                type:'POST',
                dataType:'json',
                data:data.field,
                success:function(res){
                    if (res.code == '0') {
                        layer.msg(res.msg,{icon:1,time:1500,shade:0.1})
                    } else {
                        $(".layui-btn").removeClass('layui-disabled').removeAttr('disabled');
                        wk.error(res.msg);
                        return false;
                    }
                }
            })
        });
    });
</script>
</body>

</html>